Skip to content

Add cell type filter to heightmap editor brush panel#1381

Merged
Azgaar merged 3 commits intomasterfrom
copilot/add-ocean-cells-checkbox
Apr 22, 2026
Merged

Add cell type filter to heightmap editor brush panel#1381
Azgaar merged 3 commits intomasterfrom
copilot/add-ocean-cells-checkbox

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 22, 2026

Description

Adds a cellTypeFilter select input to the heightmap editor brush panel, allowing users to restrict brush operations to all cells, only land cells, or only water cells. This prevents accidental coastline changes or new landmass creation while editing ocean depths, and vice versa.

src/index.html

  • Replaced the two separate changeOnlyLand and changeOnlyOcean checkboxes with a single <select id="cellTypeFilter"> dropdown offering three options: all cells (default), only land cells, and only water cells

public/modules/ui/heightmap-editor.js

  • Mode switching — sets cellTypeFilter.value on mode change: keep mode selects "land", erase/risk modes reset to "all"
  • updateHeightmap() — safety rollback reverts cells that crossed the h=20 land/water boundary based on the active filter
  • dragBrush() — pre-filters brush selection to land (h >= 20) or water (h < 20) cells depending on the selected filter
  • placeLinearFeature() — skips land or water cells based on the active filter
  • changeHeightForSelection()lim bounds adjusted per filter (min=20 for land-only, max=19 for water-only); brushRaise skips the ocean-to-land jump in water-only mode; brushSmooth neighbor filter respects the active filter
  • rescale() — skips out-of-filter cells and clamps output to the appropriate range
  • startFromScratch() — blocked when any non-"all" filter is active
  • cellTypeFilterChange() — new handler that prevents selecting "land" filter in keep edit mode

Copilot AI requested review from Copilot and removed request for Copilot April 22, 2026 09:05
Copilot AI linked an issue Apr 22, 2026 that may be closed by this pull request
@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 22, 2026

Deploy Preview for afmg ready!

Name Link
🔨 Latest commit 1edb1e2
🔍 Latest deploy log https://app.netlify.com/projects/afmg/deploys/69e89d26848a9e00088374ba
😎 Deploy Preview https://deploy-preview-1381--afmg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copilot AI requested review from Copilot and removed request for Copilot April 22, 2026 09:17
Copilot AI changed the title [WIP] Add checkbox to change only ocean cells in heightmap editor Add "Change Only Ocean Cells" checkbox to heightmap editor Apr 22, 2026
Copilot AI requested a review from Azgaar April 22, 2026 09:19
@Azgaar
Copy link
Copy Markdown
Owner

Azgaar commented Apr 22, 2026

@copilot, replace two checkboxes with a select input with 'check all cells', 'check only land cells' and 'check only water cells' options.

Copy link
Copy Markdown
Owner

@Azgaar Azgaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

replace two checkboxes with a select input with 'check all cells', 'check only land cells' and 'check only water cells' options.

Copilot AI requested review from Copilot and removed request for Copilot April 22, 2026 10:04
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 22, 2026

@copilot, replace two checkboxes with a select input with 'check all cells', 'check only land cells' and 'check only water cells' options.

Done in 1edb1e2. The two checkboxes are replaced with a single cellTypeFilter select in the brush panel with three options: all cells, only land cells, and only water cells. All brush operations, rescaler, and startFromScratch are updated to read from this select. The 'Keep' edit mode continues to auto-select "only land cells" and blocks switching to anything else via the change handler.

Copilot AI changed the title Add "Change Only Ocean Cells" checkbox to heightmap editor Add cell type filter to heightmap editor brush panel Apr 22, 2026
Copilot AI requested a review from Azgaar April 22, 2026 10:06
@Azgaar Azgaar marked this pull request as ready for review April 22, 2026 10:08
Copilot AI review requested due to automatic review settings April 22, 2026 10:08
@Azgaar Azgaar merged commit eceb8c5 into master Apr 22, 2026
4 checks passed
@Azgaar Azgaar deleted the copilot/add-ocean-cells-checkbox branch April 22, 2026 10:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the heightmap editor brush UI to use a single cellTypeFilter dropdown, letting users restrict edits to all cells, land-only, or water-only, to reduce accidental coastline changes during height editing.

Changes:

  • Replaces prior cell-type restriction checkboxes with a single cellTypeFilter <select> in the brush panel UI
  • Updates heightmap brush/line editing logic to honor the selected cell-type filter (including some safety rollback and rescale behavior)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/index.html Replaces the previous checkbox UI with a cellTypeFilter dropdown
public/modules/ui/heightmap-editor.js Wires the new filter into brush/line operations, rescale, and mode switching

Comment on lines +767 to +769
if (cellTypeFilter.value === "land" && heightmapEditMode.innerHTML === "keep") {
tip("You cannot change the coastline in 'Keep' edit mode", false, "error");
cellTypeFilter.value = "all";
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cellTypeFilterChange currently blocks selecting the "land" filter in "keep" mode and resets to "all". In "keep" mode the UI copy says the coastline cannot change, which requires forcing a land-only constraint (matching enterHeightmapEditMode setting cellTypeFilter.value = "land"). Consider preventing changes away from "land" while in keep mode (e.g., revert to "land" / disable the select) rather than rejecting the land option.

Suggested change
if (cellTypeFilter.value === "land" && heightmapEditMode.innerHTML === "keep") {
tip("You cannot change the coastline in 'Keep' edit mode", false, "error");
cellTypeFilter.value = "all";
if (heightmapEditMode.innerHTML === "keep" && cellTypeFilter.value !== "land") {
tip("You cannot change the coastline in 'Keep' edit mode", false, "error");
cellTypeFilter.value = "land";

Copilot uses AI. Check for mistakes.
Comment on lines 692 to 698
let selection = [];
for (let i = 0; i < heights.length; i++) {
if (changedHeights[i] === heights[i]) continue;
if (changeOnlyLand.checked && heights[i] < 20) continue;
if (cellTypeFilter.value === "land" && heights[i] < 20) continue;
if (cellTypeFilter.value === "water" && heights[i] >= 20) continue;
heights[i] = changedHeights[i];
selection.push(i);
Copy link

Copilot AI Apr 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In placeLinearFeature, the cell-type filter checks heights[i] (the pre-operation height) to decide whether to apply changedHeights[i]. This allows coastline changes to slip through (e.g., a land cell can be lowered below 20 in land-only mode, or a water cell raised above 19 in water-only mode), and this path doesn't call updateHeightmap() so the rollback logic won't correct it. Filter/clip based on the resulting height (changedHeights[i]) and/or reuse the same limiting logic used by brush editing, or call updateHeightmap() after applying the changes.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Change Ocean Cells Only

3 participants